﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using BLL;
namespace 健身房管理
{
    public partial class UserInfo : UserControl
    {
        UserInfoBLL ubl = new UserInfoBLL();
        public int random1 = 0;
        public UserInfo()
        {
            InitializeComponent();
        }

        private void UserInfo_Load(object sender, EventArgs e)
        {
            jiaz();
        }
        public void jiaz()
        {
            DataTable dt = ubl.UserInfoShow(random1.ToString());
            this.txtname.Text = dt.Rows[0]["uname"].ToString();
            this.txtmail.Text = dt.Rows[0]["mail"].ToString();
            string sex= dt.Rows[0]["sex"].ToString();
            if (sex == "男")
            {
                this.ra1.Checked = true;
            }
            else
            {
                this.ra2.Checked = true;
            }
            this.jointime.Text = dt.Rows[0]["jointime"].ToString();
            this.lbljif.Text = dt.Rows[0]["carintegral"].ToString();
            this.lblname.Text = dt.Rows[0]["uname"].ToString();
            this. txtrandom.Text= dt.Rows[0]["randomcnum"].ToString();
        }

        private void guna2Button1_Click(object sender, EventArgs e)
        {
            
            string name = this.txtname.Text;
            string mail = this.txtmail.Text;
            string sex = "";
            if (this.ra1.Checked)
            {
                sex = "男";
            }
            else
            {
                sex = "女";
            }
          int random=int.Parse( txtrandom.Text);
            int id = random1;
            bool b1 = ubl.UserInfoModify(name, mail,sex,random,id);
            if (b1)
            {
                MessageBox.Show("修改成功");
                MessageBox.Show("检测到修改个人信息请重新登录");
                this.Hide();
                Login lg = new Login();
                lg.Show();
            }
            else
            {
                MessageBox.Show("修改失败");
            }
        }
    }
}
